home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / nameserver.lha / named / portability.h < prev    next >
C/C++ Source or Header  |  1993-12-03  |  6KB  |  205 lines

  1. /* defs.h - include or define things that aren't present on all systems
  2.  * vixie@decwrl 26dec92 [new]
  3.  *
  4.  * $Id: portability.h,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $
  5.  */
  6.  
  7. /*
  8.  * ++Copyright++
  9.  * -
  10.  * Copyright (c)  Regents of the University of California.
  11.  * All rights reserved.
  12.  * 
  13.  * Redistribution and use in source and binary forms, with or without
  14.  * modification, are permitted provided that the following conditions
  15.  * are met:
  16.  * 1. Redistributions of source code must retain the above copyright
  17.  *    notice, this list of conditions and the following disclaimer.
  18.  * 2. Redistributions in binary form must reproduce the above copyright
  19.  *    notice, this list of conditions and the following disclaimer in the
  20.  *    documentation and/or other materials provided with the distribution.
  21.  * 3. All advertising materials mentioning features or use of this software
  22.  *    must display the following acknowledgement:
  23.  *     This product includes software developed by the University of
  24.  *     California, Berkeley and its contributors.
  25.  * 4. Neither the name of the University nor the names of its contributors
  26.  *    may be used to endorse or promote products derived from this software
  27.  *    without specific prior written permission.
  28.  * 
  29.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  30.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  33.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39.  * SUCH DAMAGE.
  40.  * -
  41.  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  42.  * 
  43.  * Permission to use, copy, modify, and distribute this software for any
  44.  * purpose with or without fee is hereby granted, provided that the above
  45.  * copyright notice and this permission notice appear in all copies, and that
  46.  * the name of Digital Equipment Corporation not be used in advertising or
  47.  * publicity pertaining to distribution of the document or software without
  48.  * specific, written prior permission.
  49.  * 
  50.  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  51.  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  52.  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  53.  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  54.  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  55.  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  56.  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  57.  * SOFTWARE.
  58.  * -
  59.  * --Copyright--
  60.  */
  61.  
  62. #include <string.h>
  63. #include <sys/types.h>
  64. #include <sys/param.h>
  65.  
  66. #ifdef __sgi
  67. #define BSD 43
  68. #define _POSIX_SOURCE
  69. #define vfork fork
  70. #define USE_SETSID
  71. #endif
  72.  
  73. #if defined(host_mips) && defined(SYSTYPE_BSD43)
  74. #define RISCOS_BSD
  75. #endif
  76.  
  77. /* primative but it will do for now */
  78. #if !defined(SYSV)
  79. #define USE_WAIT3
  80. #endif
  81.  
  82. #if defined(SYSV) || defined(ultrix) || (defined(BSD) && BSD >= 199306)
  83. #define USE_UTIME
  84. #endif
  85.  
  86. #if defined(BSD) && BSD >= 199006 && !defined(i386) && !defined(RISCOS_BSD)
  87. #define HAVE_DAEMON
  88. #endif
  89.  
  90. #if defined(_POSIX_SOURCE)
  91.  
  92. #include <stdlib.h>
  93. #include <unistd.h>
  94. #include <limits.h>
  95.  
  96. #else /*POSIX*/
  97.  
  98. #define NEED_STRTOUL
  99.  
  100. #define STDERR_FILENO 2
  101. extern char *getenv();
  102. extern int errno;
  103.  
  104. #ifndef DMALLOC
  105. extern char *malloc(), *realloc(), *calloc();
  106. extern void free();
  107. #endif
  108.  
  109. #endif /*POSIX*/
  110.  
  111. #ifndef UINT_MAX
  112. #ifdef __STDC__
  113. #define UINT_MAX        4294967295u             /* max value of an "u_int" */
  114. #else
  115. #define UINT_MAX        ((unsigned)4294967295)  /* max value of an "u_int" */
  116. #endif
  117. #define ULONG_MAX       UINT_MAX        /* max decimal value of a "u_long" */
  118. #endif
  119.  
  120. #ifndef INT_MAX
  121. #define INT_MAX        2147483647    /* max decimal value of an "int" */
  122. #endif
  123.  
  124. #ifndef    IN_LOOPBACKNET
  125. #define    IN_LOOPBACKNET    127
  126. #endif
  127.  
  128. #ifndef    INADDR_NONE
  129. #define    INADDR_NONE    0xffffffff
  130. #endif
  131.  
  132. #if (!defined(BSD) || (BSD <= 43)) && !defined(NeXT)
  133. extern void syslog();
  134. extern char *ctime();
  135. extern int    close(), setitimer(), recv(), sendto(), sigsetmask(),
  136.         atoi(), getpid(), fork(), read(), ioctl(),
  137.         setsockopt(), socket(), bind();
  138. #endif
  139.  
  140. #if !defined(bcopy)    /* some machines have their own macros for this */
  141. #if !defined(BSD)
  142. #define bcopy(a,b,c) memcpy(b,a,c)
  143. #define bzero(a,b) memset(a,0,b)
  144. #define bcmp(a,b,c) memcmp(a,b,c)
  145. #else
  146. extern int strcasecmp();
  147. extern int bcmp();
  148. extern void bcopy(), bzero();
  149. #endif /* BSD */
  150. #endif /* bcopy */
  151.  
  152. #if (!defined(BSD) || (BSD < 43) || defined(RISCOS_BSD)) && !defined(_POSIX_SOURCE)
  153. #define NEED_STRERROR
  154. #endif
  155.  
  156. #if (!defined(BSD) || (BSD < 43)) && !defined(ultrix)
  157. #define NEED_STRCASECMP
  158. #endif
  159.  
  160. /*
  161.  * Attempt to configure for type of function returned by signal-catching
  162.  * functions (which signal and sigvec.sv_handler take a pointer to).
  163.  * This can guess for BSD; otherwise, define SIG_FN externally.
  164.  */
  165. #ifndef    SIG_FN
  166. #ifdef    BSD
  167. #if (BSD >= 199006) || defined(NeXT) || defined(__osf__)
  168. #define SIG_FN    void        /* signal-catching functions return void */
  169. #else
  170. #define SIG_FN    int        /* signal-catching functions return int */
  171. #endif
  172. #else    /* BSD */
  173. #define SIG_FN    void        /* signal-catching functions return void */
  174. #endif    /* BSD */
  175. #endif
  176.  
  177. #if !defined(ntohl) && !defined(htonl) && defined(BSD) && (BSD <= 43)
  178. /* if these aren't null macros in netinet/in.h, extern them here. */
  179. extern u_short htons(), ntohs();
  180. extern u_long htonl(), ntohl();
  181. #endif
  182.  
  183. #if defined(_POSIX_SOURCE) && !defined(sun) && !defined(__sgi)
  184. #define    PORT_NONBLOCK    O_NONBLOCK
  185. #define    PORT_WOULDBLK    EAGAIN
  186. #else
  187. #define    PORT_NONBLOCK    O_NDELAY
  188. #define    PORT_WOULDBLK    EWOULDBLOCK
  189. #endif
  190.  
  191. #if defined(_POSIX_SOURCE)
  192. #define    USE_SETSID
  193. #endif
  194.  
  195. #if defined(__osf__) || (defined(BSD) && (BSD > 43) && !defined(RISCOS_BSD))
  196. typedef    int        WAIT_T;
  197. #else
  198. typedef    union wait    WAIT_T;
  199. #endif
  200.  
  201. #if (!defined(WEXITSTATUS)) || (!defined(WTERMSIG))
  202. #define WEXITSTATUS(x) (x).w_retcode
  203. #define WTERMSIG(x) (x).w_termsig
  204. #endif
  205.